package it.mvc.layoutmanager;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;

public class DynamicGridLayout implements LayoutManager2 {

	private final int defaultSize=10;
	private ComponentMover mover=new DynamicComponentMover();
	private ComponentResizer resizer=new DynamicComponentResizer();
	public DynamicGridLayout() {
		mover=new DynamicComponentMover();
		resizer=new DynamicComponentResizer();
		
	}
	

	
	@Override
	public void addLayoutComponent(String name, Component comp) {
		// TODO Auto-generated method stub

	}

	@Override
	public void removeLayoutComponent(Component comp) {
		mover.deregisterComponent(comp);
		resizer.deregisterComponent(comp);

	}

	@Override
	public Dimension preferredLayoutSize(Container parent) {
		// TODO Auto-generated method stub
		return new Dimension(1000,100);
	}

	@Override
	public Dimension minimumLayoutSize(Container parent) {
		// TODO Auto-generated method stub
		return null;
	}
	

	@Override
	public void layoutContainer(Container parent) {
		
	} 
	

	@Override
	public void addLayoutComponent(Component comp, Object constraints) {
		mover.registerComponent(comp);
		resizer.registerComponent(comp);
	}



	@Override
	public Dimension maximumLayoutSize(Container target) {
		// TODO Auto-generated method stub
		return null;
	}



	@Override
	public float getLayoutAlignmentX(Container target) {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public float getLayoutAlignmentY(Container target) {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public void invalidateLayout(Container target) {
		// TODO Auto-generated method stub
		
	}
	
	
	private class DynamicComponentResizer extends ComponentResizer{
		public DynamicComponentResizer() {
			super();
		}
	}
	
	private class DynamicComponentMover extends ComponentMover{
		public DynamicComponentMover() {
			super();
		}
		@Override
		public boolean isDragEnable() {
			// TODO Auto-generated method stub
			return resizer.notInResizeMode();
		}
		
	}
	
	
	
}
